<template>
	<view>
		<page-head :title="'评论'" :headtype="2"></page-head>
		<view class="ev marginAuto">
			<view class="evtitle">我的评价</view>
			<view class="evtxt marginAuto">
				<textarea v-model="evtxt" maxlength="999" placeholder="请用简短的几句话描述一下对产品的使用情况吧~"></textarea>
			</view>
			<view class="evzh flex">
				<view class="evzhtitle">综合评价: </view>
				<view class="evzhxing flex">
					<uv-icon class="gradetxtxingeach" @click="xing = 1" :name="xing >= 1 ? 'star-fill':'star'" size="24" color="#FF9D0A"></uv-icon>
					<uv-icon class="gradetxtxingeach" @click="xing = 2" :name="xing >= 2 ? 'star-fill':'star'" size="24" color="#FF9D0A"></uv-icon>
					<uv-icon class="gradetxtxingeach" @click="xing = 3" :name="xing >= 3 ? 'star-fill':'star'" size="24" color="#FF9D0A"></uv-icon>
					<uv-icon class="gradetxtxingeach" @click="xing = 4" :name="xing >= 4 ? 'star-fill':'star'" size="24" color="#FF9D0A"></uv-icon>
					<uv-icon class="gradetxtxingeach" @click="xing = 5" :name="xing >= 5 ? 'star-fill':'star'" size="24" color="#FF9D0A"></uv-icon>
				</view>
			</view>
		</view>
		<view class="anonymity marginAuto flex" @click="nname = !nname">
			<view class="anonymityicon">
				<uv-icon v-if="nname" style="position: absolute;top:-2rpx;left:-2rpx;" name="checkmark-circle-fill" size="30" color="#0089FB"></uv-icon>
			</view>
			<view class="anonymitytitle">匿名评价</view>
		</view>
		<view class="marginAuto" style="width:600rpx;margin-top:100rpx;">
			<uv-button text="提交" @click="enter()" :customStyle="{
				'background':'#1686F8',
				'color':'#fff',
				'font-size':'30rpx',
				'width':'600rpx',
				'height':'100rpx',
				'border-radius':'100rpx'
			}"></uv-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				jlid:'',
				evtxt:'',
				xing:3,
				nname:false
			};
		},
		onLoad(option) {
			this.jlid = option.jlid
		},
		methods: {
			enter(){
				let sendData = {
					score:this.xing,
					coach_id:this.jlid,
					anonymity:this.nname ? 1 : 0,
					content:this.evtxt
				}
				if(this.evtxt == ''){
					this.apifun.toast('请输入评价内容');
					return false
				};
				this.apifun.unirequest('/api/partnerDrive/evaluate','post',sendData,(res)=>{
					// console.log(res)
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('评价成功');
						setTimeout(()=>{
							uni.reLaunch({
								url:"/pages/tabbar/my"
							})
						},1500)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		},
	};
</script>

<style scoped lang="scss">
	.ev{
		width: 630rpx;
		padding:30rpx;
		background: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
		.evtitle{
			font-size: 32rpx;
			color: #333333;
			padding: 0rpx 0 20rpx;
		}
		.evtxt{
			width:94%;
			padding: 10rpx 3%;
			height: 300rpx;
			background:#F7F7F7;
			border-radius: 20rpx;
			textarea{
				width: 100%;
				line-height:40rpx;
				font-size: 30rpx;
				color: #333;
			}
		}
		.evzh{
			padding: 20rpx 0;
			.evzhtitle{
				line-height:50rpx;
				margin-right: 10rpx;
				font-size: 34rpx;
				color:#333333;
			}
			.evzhxing{
				.gradetxtxingeach{
					margin-right:5rpx;
				}
			}
		}
	}
	.anonymity{
		width: 690rpx;
		padding: 20rpx 0;
		.anonymityicon{
			position: relative;
			width:50rpx;
			height: 50rpx;
			border-radius: 100rpx;
			border: 1px solid #E7E7E7;
			background: #fff;
		}
		.anonymitytitle{
			color: #9E9E9E;
			font-size: 30rpx;
			line-height:50rpx;
			margin-left: 10rpx;
		}
	}
</style>